import heapq

def nthSuperUglyNumber(n, primes):
    m = len(primes)
    dp = [1] * n
    pq = [(p, 0, i) for i, p in enumerate(primes)]
    for i in range(1, n):
        dp[i] = pq[0][0]
        while pq and pq[0][0] == dp[i]:
            _, idx, p = heapq.heappop(pq)
            heapq.heappush(pq, (dp[idx + 1] * primes[p], idx + 1, p))
    return dp[-1]

n = int(input())
primes = [int(x) for x in input().split(" ")]
print(nthSuperUglyNumber(n, primes))

